import request from "@/utils/request";
import { getParamsSuffix } from "@/utils/paramsUtils";


/**
 * 分页
 * @param params
 * @returns {Promise<any>}
 */
export async function selList(params) {
  return request('/api/cdcerservice/v1/task/selList', {
    method: 'POST',
    requestType: 'form',
    data: { ...params },
  });
}


/**
 * 获取所有省份数据
 * @param query
 * @returns {Promise<any>}
 */
export async function getAllProvince() {
  return request(`/api/cdcerservice/v1/orgsetting/getAllProvince`);
}


/**
 * 查询市区街道级联
 * @returns {Promise<any>}
 * @param query
 */
export async function getAllProvinceCity(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/orgsetting/getAllProvinceCity?${params}`);
}

/**
 * 获取城市下的区街道信息
 * @returns {Promise<any>}
 * @param query
 */
export async function getDistrictAndStreet(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/orgsetting/getDistrictAndStreet?${params}`);
}


/**
 * 筛选机构
 * @param query
 * @returns {Promise<any>}
 */
export async function listAllData(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/orgsetting/listAllData?${params}`);
}


/**
 * 添加保存
 * @param params
 * @returns {Promise<any>}
 */
export async function add(params) {
  return request('/api/cdcerservice/v1/task/add', {
    method: 'POST',
    requestType: 'form',
    data: { ...params },
  });
}

/**
 * 编辑保存
 * @param params
 * @returns {Promise<any>}
 */
export async function edit(params) {
  return request('/api/cdcerservice/v1/task/edit', {
    method: 'POST',
    requestType: 'form',
    data: { ...params },
  });
}

/**
 * 详情
 * @param query
 * @returns {Promise<any>}
 */
export async function selById(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/task/selById?${params}`);
}

/**
 * 删除
 * @param query
 * @returns {Promise<any>}
 */
export async function del(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/task/del?${params}`);
}

/**
 * 点击导出所有信息
 * @returns {Promise<any>}
 * @param params
 */
export async function queryAllExportData(params) {
  return request(`/api/cdcerservice/v1/task/queryAllExportData`, {
    method: 'POST',
    requestType: 'form',
    responseType: 'blob',
    data: {
      ...params
    }
  });
}

/**
 * 封库
 * @param query
 * @returns {Promise<any>}
 */
export async function changeStatus(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/task/changeStatus?${params}`);
}
